<template>
  <div class="monitor-box">
    <CardBox title="固定样地"> </CardBox>
    <div class="content-container">
      <div class="card sample-card">
        <div class="card-content">
          <div class="radar-chart">
            <div class="radar-grid">
              <div class="radar-circle" v-for="n in 4" :key="n"></div>
            </div>
            <div
                    v-for="(item, index) in sampleData"
                    :key="item.type"
                    class="radar-point"
                    :style="getRadarPosition(index, sampleData.length, item.value / maxSampleValue)"
                    :class="`point-${index % 7 + 1}`"
            >
              <div class="point-value">{{ item.value }}个</div>
              <div class="point-label">{{ item.label }}</div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import CardBox from "@/components/Global/CardBox.vue";

export default {
  name: "Monitor",
  components: {
    CardBox,
  },
  data() {
    return {
      activeType: null,
      sampleData: [
        { type: 'broadleaf', label: '阔叶混交林', value: 6 },
        { type: 'evergreen-conifer', label: '常绿针叶林', value: 1 },
        { type: 'evergreen', label: '常绿阔叶林', value: 2 },
        { type: 'coniferous', label: '针阔混交林', value: 4 },
        { type: 'deciduous-conifer', label: '落叶针叶林', value: 2 },
        { type: 'deciduous', label: '落叶阔叶林', value: 4 },
        { type: 'bamboo', label: '竹林', value: 1 }
      ],
    };
  },
  computed: {
    maxSampleValue() {
      return Math.max(...this.sampleData.map(item => item.value)) + 1;
    }
  },
  methods: {
    getRadarPosition(index, total, radius) {
      const angle = (index / total) * Math.PI * 2 - Math.PI / 2;
      const x = 50 + Math.cos(angle) * radius * 40;
      const y = 50 + Math.sin(angle) * radius * 40;
      return {
        left: `${x}%`,
        top: `${y}%`
      };
    }
  }
};
</script>

<style lang="scss" scoped>
  @import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;700&display=swap');
  @import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css');

  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }

  .monitoring-dashboard {
    font-family: 'Orbitron', sans-serif;
    background-color: #0a0e17;
    color: #e0e0e0;
    width: 500px;
    height: 560px;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
    overflow-y: auto;
  }

  .monitoring-dashboard::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
            radial-gradient(circle at 20% 30%, rgba(0, 100, 150, 0.1) 0%, transparent 50%),
            radial-gradient(circle at 80% 70%, rgba(0, 150, 100, 0.1) 0%, transparent 50%);
    z-index: 0;
  }

  .card-container {
    display: flex;
    margin-bottom: 15px;
  }

  .card-title {
    width: 120px;
    background: rgba(16, 22, 36, 0.8);
    border-radius: 8px 0 0 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 15px;
    border-right: 1px solid rgba(79, 172, 254, 0.2);
  }

  .title-text {
    font-size: 16px;
    color: #4facfe;
    margin-bottom: 8px;
    text-align: center;
  }

  .title-value {
    font-size: 24px;
    font-weight: 700;
    color: #00f2fe;
    text-align: center;
  }

  .card {
    border-radius: 0 8px 8px 0;
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
    position: relative;
    flex: 1;
  }

  .card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;

  }


  .card-content {
    padding: 15px;
    height: 100%;
  }

  /* 物种观测设备样式 */
  .species-card .data-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .data-item {
    background: rgba(25, 35, 60, 0.5);
    border-radius: 6px;
    padding: 12px;
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
    transition: all 0.3s;
    border: 1px solid rgba(79, 172, 254, 0.1);
    height: 80px;
  }

  .data-item:hover {
    background: rgba(25, 35, 60, 0.8);
  }

  .data-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    position: relative;
  }

  .data-icon .icon-bg {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    opacity: 0.2;
  }

  .data-icon i {
    font-size: 16px;
    z-index: 1;
  }

  .data-icon.infrared .icon-bg {
    background: #ff4d4d;
  }

  .data-icon.infrared i {
    color: #ff4d4d;
  }

  .data-icon.sound .icon-bg {
    background: #4d79ff;
  }

  .data-icon.sound i {
    color: #4d79ff;
  }

  .data-icon.video .icon-bg {
    background: #4dffb8;
  }

  .data-icon.video i {
    color: #4dffb8;
  }

  .data-icon.insect .icon-bg {
    background: #ffb84d;
  }

  .data-icon.insect i {
    color: #ffb84d;
  }

  .data-info {
    flex: 1;
  }

  .data-value {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 3px;
    background: linear-gradient(90deg, #00f2fe, #4facfe);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }

  .data-label {
    font-size: 12px;
    color: #a0a0a0;
  }

  .data-wave {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(79, 172, 254, 0.5), transparent);
    opacity: 0;
    transition: opacity 0.3s;
  }

  .data-wave.active {
    opacity: 1;
  }

  /* 环境监测设备样式 */
  .environment-card .gauge-container {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    height: 120px;
  }

  .gauge-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
  }

  .gauge-title {
    font-size: 11px;
    margin-bottom: 8px;
    color: #a0a0a0;
    text-align: center;
  }

  .gauge-wrapper {
    width: 25px;
    height: 80px;
    background: rgba(25, 35, 60, 0.5);
    border-radius: 12px;
    display: flex;
    flex-direction: column-reverse;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(79, 172, 254, 0.1);
  }

  .gauge-fill {
    width: 100%;
    transition: height 1s ease-out;
    border-radius: 12px;
  }

  .gauge-fill.color-1 {
    background: linear-gradient(to top, #00f2fe, #4facfe);
  }

  .gauge-fill.color-2 {
    background: linear-gradient(to top, #4d79ff, #4dffb8);
  }

  .gauge-fill.color-3 {
    background: linear-gradient(to top, #ff4d4d, #ffb84d);
  }

  .gauge-fill.color-4 {
    background: linear-gradient(to top, #b84dff, #4dffb8);
  }

  .gauge-value {
    font-size: 12px;
    margin-top: 8px;
    font-weight: 500;
    color: #4facfe;
  }

  /* 固定样地样式 */
  .sample-card .radar-chart {
    width: 100%;
    height: 245px;
    position: relative;
  }

  .radar-grid {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
  }

  .radar-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 1px dashed rgba(78, 174, 255, 0.52);
  }

  .radar-circle:nth-child(1) {
    width: 20%;
    height: 20%;
  }

  .radar-circle:nth-child(2) {
    width: 40%;
    height: 40%;
  }

  .radar-circle:nth-child(3) {
    width: 60%;
    height: 60%;
  }

  .radar-circle:nth-child(4) {
    width: 80%;
    height: 80%;
  }

  .radar-point {
    position: absolute;
    transform: translate(-50%, -50%);
    text-align: center;
    transition: all 0.5s;
    font-size: 11px;
  }

  .point-value {
    color: #fff;
    font-weight: 700;
    margin-bottom: 3px;
  }

  .point-label {
    color: #a0a0a0;
  }

  .radar-point::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    z-index: -1;
    opacity: 0.7;
  }

  .radar-point:hover::before {
    animation: pulse 1.5s infinite;
  }

  .point-1::before { background: #00f2fe; }
  .point-2::before { background: #4facfe; }
  .point-3::before { background: #4d79ff; }
  .point-4::before { background: #4dffb8; }
  .point-5::before { background: #ffb84d; }
  .point-6::before { background: #ff4d4d; }
  .point-7::before { background: #b84dff; }

  /* 动画效果 */
  @keyframes pulse {
    0% {
      transform: translate(-50%, -50%) scale(1);
      opacity: 0.7;
    }
    70% {
      transform: translate(-50%, -50%) scale(2.5);
      opacity: 0;
    }
    100% {
      transform: translate(-50%, -50%) scale(1);
      opacity: 0;
    }
  }

.content-container {
  height: 245px;
}
.description {
  font-size: 15px;
  line-height: 1.6;
  color: #fff;
  padding: 7px 18px;
  text-indent: 4ch;
  letter-spacing: 3px;
}
.monitor-total {
  display: flex;
  flex-wrap: wrap;
  gap: 50px;
  padding: 13px 20px;
}

.monitor-total-item {
  flex: 1;
  text-align: center;
}
.monitor-total-item-icon {
  margin-right: 10px;
}
.monitor-total-item-content {
  position: relative;
}
.monitor-total-item-title {
  font-size: 16px;
  margin-bottom: 8px;
  color: rgba(255, 255, 255, 0.8);
}
.monitor-total-item-bg {
  position: absolute;
  bottom: -30px;
  left: 24px;
  width: 68px;
  height: 35px;
}
.monitor-total-item-num {
  font-size: 28px;
  color: #fff;
  margin-bottom: 18px;
}
.monitor-total-item-num-unit {
  font-size: 12px;
  margin-left: 5px;
}
</style>